package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.CreditsCategoryDictMapper;
import com.ghck.server.model.CreditsCategoryDict;
import com.ghck.server.model.query.CreditsCategoryDictQuery;
import com.ghck.server.service.CreditsCategoryDictService;

/**
 * 积分类型  <br>
 * dict_credits_category <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class CreditsCategoryDictServiceImpl implements CreditsCategoryDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(CreditsCategoryDictServiceImpl.class);
	
	@Autowired
	private CreditsCategoryDictMapper creditsCategoryDictMapper;
	
	/**
 	*根据ID删除 积分类型
 	*/
 	@Override
 	public Integer deleteCreditsCategoryDictById(Integer id){
 		return creditsCategoryDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 积分类型
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertCreditsCategoryDict(List<? extends CreditsCategoryDict> creditsCategoryDicts){
		Integer count = creditsCategoryDictMapper.batchInsert(creditsCategoryDicts);
		return count;
 	}
 	/**
 	*新增 积分类型
 	*/
 	@Override
 	@Transactional
 	public Integer insertCreditsCategoryDict(CreditsCategoryDict domain){
		Integer id = creditsCategoryDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 积分类型
 	*/
 	@Override
 	@Transactional
 	public Integer updateCreditsCategoryDict(CreditsCategoryDict domain){
		Integer count = creditsCategoryDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 积分类型
 	*/
 	public CreditsCategoryDict findCreditsCategoryDictById(Integer id){
 		CreditsCategoryDict result = creditsCategoryDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 积分类型
 	*/
	public List<CreditsCategoryDict> findCreditsCategoryDictByQuery(CreditsCategoryDictQuery query){
		query.dealWith();
		List<CreditsCategoryDict> result = creditsCategoryDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsCategoryDict creditsCategoryDict : result) {
				creditsCategoryDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countCreditsCategoryDictByQuery(CreditsCategoryDictQuery query){
 		query.dealWith();
 		Integer result = creditsCategoryDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<CreditsCategoryDict> findCreditsCategoryDictByIds(List<Integer> ids){
 		List<CreditsCategoryDict> result = creditsCategoryDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsCategoryDict creditsCategoryDict : result) {
				creditsCategoryDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public CreditsCategoryDict findByName(String name){
		CreditsCategoryDict result = creditsCategoryDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<CreditsCategoryDict> findAll(){
		List<CreditsCategoryDict> result = creditsCategoryDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (CreditsCategoryDict creditsCategoryDict : result) {
				creditsCategoryDict.dealWith();
			}
		}
		return result;
	}
}	